package com.dragon.app.practice;

import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.CancellationException;

public class Practice1 {
	
	
	/**
	 * 编程输出一个倒立三角形图。
	 	******
	 	*****
	 	****
	 	***
	 	**
	 	*
	 * 
	 * @param n
	 */
	public static void printStar(int n) {
		for (int i = 0; i < n; ++i) {
			for (int j = n; j > i; j--) {
				System.out.print("*");
			}
			System.out.println();
		}
	}
	
	/**
	 * 打印昨天的当前时刻。
	 */
	public static void printYesterday() {
		Calendar cal = Calendar.getInstance();
		cal.setTime(new Date());
		cal.add(Calendar.DATE, -1);
		System.out.println(cal.getTime());
	}
	
	
	/**
	 * 编写程序，取得当前时间的年月日，小时分秒。
	 */
	public static void printDateDetail() {
		Calendar cal = Calendar.getInstance();
		System.out.println(cal.get(Calendar.YEAR));
		System.out.println(cal.get(Calendar.MONTH) + 1);
		System.out.println(cal.get(Calendar.DATE));
		System.out.println(cal.get(Calendar.HOUR_OF_DAY));
		System.out.println(cal.get(Calendar.MINUTE));
		System.out.println(cal.get(Calendar.SECOND));
	}
	
	
	
	public static void main(String[] args) {
		printStar(8);
		
		printYesterday();
		
		printDateDetail();
		
	}

}
